package com.alliky.home.ui.viewmodel;

import android.graphics.drawable.Drawable;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.databinding.ObservableField;

import com.alliky.core.base.ItemViewModel;
import com.alliky.core.binding.command.BindingAction;
import com.alliky.core.binding.command.BindingCommand;
import com.alliky.core.bus.RxMessager;
import com.alliky.core.entity.vo.GoodsVO;
import com.alliky.core.util.RxToast;
import com.alliky.home.R;

import org.jetbrains.annotations.NotNull;

public class HomeHotItemViewModel extends ItemViewModel<HomeViewModel> {

    public ObservableField<GoodsVO> goodsVO = new ObservableField<>();

    public ObservableField<Integer> bgColorId = new ObservableField();
    public Drawable mDrawable;


    public HomeHotItemViewModel(@NonNull @NotNull HomeViewModel viewModel, GoodsVO goodsVO) {
        super(viewModel);
        this.goodsVO.set(goodsVO);
        mDrawable = ContextCompat.getDrawable(viewModel.getApplication(), R.mipmap.icon_default);
//        bgColorId = ContextCompat.getDrawable(viewModel.getApplication(), R.drawable.common_round_white8);
    }

    //item点击事件
    public BindingCommand onItemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            RxMessager.getDefault().send(goodsVO.get(), HomeViewModel.KEY_CLICK_ITEM);
        }
    });
}
